const initialState = {
    userInfo: null,
    news: {},
    from: {},
    navIndex: null,

    // 测试数据，saga用
    userList: []
}

interface StoreAction {
    type: string;
    payload: any;
}
export const storeData = (state = initialState, action: StoreAction) => {
    const { type, payload} = action;
    switch (type) {
        case 'SET_USER_INFO':
            return {
                ...state,
                ...payload
            }

        case 'SET_NEWS':
            return {
                ...state,
                ...payload
            }

        case 'SET_FROM':
            return {
                ...state,
                ...payload
            }

        case 'SET_NAV_INDEX':
            return {
                ...state,
                ...payload
            }


        //  测试saga用
        case 'SET_USER_LIST':
            return {
                ...state,
                userList: payload
            }
        default:
            return state
    }
}
